package chat;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class Udpreceive {
    public static void main(String[] args) throws Exception {
        DatagramSocket socket=new DatagramSocket(6666);
            //接收数据
        while (true) {
            byte[] bus = new byte[1024];
            DatagramPacket packet = new DatagramPacket(bus, 0, bus.length);
            socket.receive(packet);
            String str=new String(packet.getData(), 0, packet.getLength());
            System.out.println(str);
        }
    }
}
